<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Model extends CI_Controller {
	
	public function index()
	{
		echo "Model index";
	}
	public function show($mid){
		$tag = date('Ymd');
		$ser = 'http://'.$_SERVER['SERVER_NAME'];
		if (session_id() == "") session_start();
		$uid = @$_SESSION["uid"];
		$is_login = isset($_SESSION["username"]) && isset($_SESSION["uid"]);
		
		$this->load->model('product', 'product');
		$model_info = $this->product->get_model_info($mid);
		
		$model_pictures = $this->product->get_model_pictures($mid);
		$model_material = $this->product->get_model_material($mid);
		$model_comments = $this->product->get_model_comments($mid);
		
		if (FALSE){
			$is_favorites = $this->product->is_favorites($uid, $mid);
			$is_wishlist = $this->product->is_wishlist($uid, $mid);
			$data['is_favorites'] = $is_favorites;
			$data['is_wishlist'] = $is_wishlist;
		}
		$model_favorites = $this->product->get_more_favorited($mid);
		$model_designs = $this->product->get_more_designs($mid);
		$model_keys = $this->product->get_model_keys($mid);
		
		$cart_count = 0;
		if ($is_login){
			$cart_count = @$_SESSION["cart_count"];
		}
		$data['cart_count'] = $is_login;
		$data['is_login'] = $is_login;
		$data['ser'] = $ser;
		$data['tag'] = $tag;
		$data['model_info'] = $model_info;
		$data['model_pictures'] = $model_pictures;
		$data['model_comments'] = $model_comments;
		$data['model_favorites'] = $model_favorites;
		$data['model_designs'] = $model_designs;
		$data['model_keys'] = $model_keys;
		$this->load->view("model/show",$data);
	}
	public function edit($li){
// 		echo "edit model";
		$this->load->view("model/edit");
	}
}